#include "insertion_sort.h"

namespace algo
{

void insertion_sort(vector<int> &vctNums)
{
    if (vctNums.size() <= 1)
    {
        return ;
    }

    for (int i = 1; i < vctNums.size(); ++i)
    {
        int value = vctNums[i];
        int j = i - 1;
        for (; j >= 0; --j)
        {
            if (value < vctNums[j])
            {
                vctNums[j+1] = vctNums[j];
            }
            else
            {
                break;
            }
        }
        vctNums[j+1] = value;
    }

    return ;
}

}
